<template>
  <el-select v-model="value" placeholder="请选择" style="margin-right: 10px" @change="companySelectChange">
    <el-option label="全部" value="" />
    <el-option
      v-for="item in options"
      :key="item.id"
      :label="item.name"
      :value="item.id"
    />
  </el-select>
</template>

<script>
import { getCompanyList } from '@/api/user'
export default {
  data() {
    return {
      options: [],
      value: ''
    }
  },
  created() {
    this.getCompanyList()
  },
  methods: {
    getCompanyList() {
      getCompanyList().then(res => {
        const { data: { data }} = res
        this.options = data
      })
    },
    companySelectChange(val) {
      this.$emit('companySelectChange', val)
    }
  }
}
</script>
